package com.cxs.model;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

/**
 * @Author: cxs
 */
@Data
@AllArgsConstructor
@NoArgsConstructor
public class R<T> {

    private Integer code = 200;
    private String msg = "操作成功";
    private T data;

    public static <T> R<T> success(T data) {
        R<T> r = new R<>();
        r.setData(data);
        return r;
    }

    public static <T> R<T> success() {
        return success(null);
    }


    public static <T> R<T> fail(Integer code, String msg) {
        R<T> r = new R<>();
        r.setCode(code);
        r.setMsg(msg);
        return r;
    }
}
